{% extends "base.html" %}

{% block content %}
    <h2>历史温度数据</h2>
    <table class="history-table">
        <thead>
            <tr>
                <th>日期</th>
                <th>相机总数</th>
                <th>故障相机数</th>
                <th>故障相机列表</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {% for item in history %}
            <tr class="{% if item.faulty_cameras > 0 %}has-faulty{% endif %}">
                <td>{{ item.date }}</td>
                <td>{{ item.total_cameras }}</td>
                <td class="{% if item.faulty_cameras > 0 %}faulty-count{% endif %}">
                    {{ item.faulty_cameras }}
                </td>
                <td>
                    {% if item.faulty_cameras > 0 %}
                        <span class="faulty-cameras">
                        {% for cam in item.faulty_list %}
                            <span class="faulty-camera">{{ cam }}</span>
                        {% endfor %}
                        </span>
                    {% else %}
                        <span class="no-faulty">无</span>
                    {% endif %}
                </td>
                <td><a href="{{ url_for('day_temperature', date=item.date) }}" class="btn">查看详情</a></td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
{% endblock %}
